package com.aistar.controller;

import com.aistar.pojo.*;
import com.aistar.service.*;
import com.aistar.util.ServerResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

@Controller
@RequestMapping("/order")
public class OrderController {
    @Autowired
    private ProductService productService;
    @Autowired
    private AddressService addressService;
    @Autowired
    private ProductImagesService productImagesService;
    @Autowired
    private DiscountService discountService;
    @Autowired
    private OrderService orderService;
    @Autowired
    private OrderDetailsService orderDetailsService;
    @Autowired
    private CartService cartService;
    @Autowired
    private CartDetailsService cartDetailsService;
    @Autowired
    private CustomerService customerService;


  //根据用户id 获取到订单列表（多个）
    @GetMapping("/getAll/{customerId}")
    @ResponseBody
    public ServerResponse getOrderByCustomerId(@PathVariable("customerId") Integer customerId){
        ServerResponse serverResponse = orderService.getOrderAndAddressByCustomerId(customerId);
        return  serverResponse;
    }

    //页面的跳转
    @RequestMapping(value = "/toDetails/{orderId}")
    public ModelAndView toDetails(@PathVariable("orderId")Integer orderId){
        ModelAndView modelAndView = new ModelAndView("/order/details");
        modelAndView.addObject("orderId",orderId);
        return modelAndView;
    }





}
